#ifndef __ALIYUN_MODEL_H
#define __ALIYUN_MODEL_H

#include "bsp.h"

#define DOUT_MAX_CH	6
#define DIN_MAX_CH	6
//数字量输出通道
#define DOUT1_NAME		digital_output1
#define DOUT2_NAME		digital_output2
#define DOUT3_NAME		digital_output3
#define DOUT4_NAME		digital_output4
#define DOUT5_NAME		digital_output5
#define DOUT6_NAME		digital_output6
//数字量输入通道
#define DIN1_NAME			digital_input1
#define DIN2_NAME			digital_input2
#define DIN3_NAME			digital_input3
#define DIN4_NAME			digital_input4
#define DIN5_NAME			digital_input5
#define DIN6_NAME			digital_input6
//状态文本
#define STATUS_NAME		statues_text
//地理位置
#define GEO_LOCATION														GeoLocation
#define GEO_LOCATION_COORDINATESYSTEM						CoordinateSystem
#define GEO_LOCATION_LATITUDE										Latitude
#define GET_LOCATION_LONGITUDE									Longitude
#define GET_LOCATION_ALTITUDE										Altitude


#define SERVER_FUNCTION_ITEM	5
#define SERVER_FUNCTION1	RegisterFingerprint
#define SERVER_FUNCTION2	RemoveAllFingerprint
#define SERVER_FUNCTION3	IdentifyFingerprint

#define SERVER_FUNCTION4	SetHoldTime
#define SERVER_FUNCTION5	NC_FUNC5

//获取属性的字符串
#define _GET_LOCATION_JSON(a)		Get_##a##_Json	
//@ 用于宏参数展开
#define GET_LOCATION_JSON(a)		_GET_LOCATION_JSON(a)
#define GET_LOCATION_JSON_FUN 	GET_LOCATION_JSON(GEO_LOCATION)

typedef struct
{
	u8 GEO_LOCATION_COORDINATESYSTEM;
	double GEO_LOCATION_LATITUDE;
	double GET_LOCATION_LONGITUDE;
	double GET_LOCATION_ALTITUDE;
}AM_GEO_LOCATION;

typedef struct
{
	u8 val;
	u8 name[16];
}AM_DOUT_MAPPING;

typedef struct
{
	u8 val;
	u8 name[16];
}AM_DIN_MAPPING;

typedef struct
{
	u8 name[32];
	void (*p_func)();
}AM_FUNC_SERVER_MAPPING;

typedef struct
{
	u8 name[16];
	u8 text[32];
}AM_TEXT_MAPPING;

void AM_Init(void);

void AM_RegisterFingerprint(void);
void AM_RemoveAllFingerprint(void);

void SERVER_FUNCTION1(void);
void SERVER_FUNCTION2(void);
void SERVER_FUNCTION3(void);
void SERVER_FUNCTION4(void);
void SERVER_FUNCTION5(void);

//获取位置的 JSON 字符串
void GET_LOCATION_JSON_FUN(char * buf);

void AM_RefreshOutputChannel(void);
void AM_RefreshOutputCH(u8 ch);
void AM_GeoLocation(void);

void AM_BuildStatuesText(char * text,u8 * result_buff);

extern AM_DOUT_MAPPING dout_map[DOUT_MAX_CH];
extern AM_DIN_MAPPING din_map[DIN_MAX_CH];
extern AM_FUNC_SERVER_MAPPING server_funcs[SERVER_FUNCTION_ITEM];
extern AM_TEXT_MAPPING statues_text;
extern AM_GEO_LOCATION geo_location;



#endif